#include "list.h"

list* createList(void* data)
{
  list* l = malloc(sizeof(list));
  l->next = NULL;
  l->data = data;
  return l;
} 

list* addElementToList(void* data, list* l)
{
  list* element = malloc(sizeof(list));
  element->data = data;
  element->next = l;
  return element;
}

list* removeElementList(list* l)
{
  list* temp = (list*)(l->next);
  free(l);
  return temp;
}

void dumpList(list* l)
{
  #ifdef DEBUG
  printf("DUMPING LIST\n");
  int i = 0;
  while(l != NULL)
    {
      printf("Element %d : %p\n", i++, l->data);
      l = l->next;
    }
  #endif
}

int existInList(void* data, list* l)
{
  while(l!=NULL)
    {
      if (l->data == data)
	return 1;
      l = l->next;
    }
  return 0;
}
